<?php
/**
 * mysql读数据
 * author:oblank
 * date:2011-05-22
 */
include_once( '../drivers/mysql.php' );
include_once( 'config.php' );

$db = $_GET['db'];
$table = $_GET['table'];	//表
$concur = $_GET['concur'];	//并发
$total = $_GET['total'];	//数量

if(!$concur || !$total){
	echo "error: set talbe、concurrent number or total read number ";
	exit;
}

$params = array ( 
		'where' => array( 'nid'=>mt_rand(0, 100000) ),
		/*
		'limit' => array ( 
				'offset' => 0, 
				'length' => 5 
		),
		'order' => ''
		*/
);
$fileds = array('*');

//db connect
extract($db_mysql);
$dbObj = new mysql ($host, $user, $password, $db );//不使用config中的db

//start time
list($usec, $sec)  =  explode( " ", microtime() );
$start_time = (float)$usec + (float)$sec;

$data = $dbObj->findAll($fileds, $table, $params);
echo $data[0]['id']."\n";

//end time
list($usec, $sec)  =  explode( " ", microtime() );
$end_time = (float)$usec + (float)$sec;

file_put_contents('logs/read_mysql_'.$concur."_".$total."_".$db."_".$table.'.log', "\n	$start_time	$end_time	".($end_time-$start_time)*10000, FILE_APPEND);
?>